<%@ page import="com.demo.javabean.UserBean"%>
<%
	//get parameters
	String username = request.getParameter("username");
	String password1 = request.getParameter("password1");
	String password2 = request.getParameter("password2");
	String email = request.getParameter("email");
	
	//check null
	if (username.equals("") || password1.equals("") || password2.equals("") || !password1.equals(password2)) 
		response.sendRedirect("register.jsp");
	else {
		//validate
		UserBean userbean = new UserBean();
		boolean isExist = userbean.isExist(username);
		if (!isExist) {
			userbean.add(username, password1, email);
			response.sendRedirect("login.jsp");
		}	
		else
			response.sendRedirect("register.jsp");
	}
%>
		